import request from '../utils/request'
import qs from 'qs'
import {Toast} from 'antd-mobile'
import {routerRedux} from 'dva/router'
let index = {
    namespace: 'info',
    state: {
        data:[]
    },
    effects:{
        *getGeniusInfo({payload},{call,put}){
            //console.log('123');
            //console.log(payload);
            let res = yield call(request('/getGeniusInfo',{method:'post',data:qs.stringify({type:payload})}));
            //console.log(res);
            if(res.status ==200){
                if(res.data.code ==0){
                    yield put({type:'initData',payload:res.data.data});
                }else if(res.data.code == 1){
                    Toast.info('您还未登录',2);
                    yield put(routerRedux.push('/login'));
                }
            }else{
                Toast.info('网络繁忙，请稍后再试');
            }
        }
    },
    reducers:{
        initData(state,{payload}){
            return{
                data:payload
            }
        },
        
    }
}
export default index;